# -*- coding: utf-8 -*-
# author: sixmillions
# date: 2022/4/3

'''
array常用函数
'''
import numpy as np

arr_1 = np.random.randint(10, size=20).reshape(4, 5)
print(1, arr_1)

# 数组中元素去重
print(2, np.unique(arr_1))

# 每一列求和
print(3, sum(arr_1))

# 某一行求和
print(4, sum(arr_1[0]))

# 某一列求和
print(5, sum(arr_1[:, 2]))

# 元素求和
print(6, sum(sum(arr_1)))
print(6, np.sum(arr_1))

# 最大元素(最小值同理)
print(7, arr_1.max())
print(7, np.max(arr_1))
# 某一行最大值
print(9, max(arr_1[1]))
# 某一列最大值
print(10, max(arr_1[:, 1]))
